package com.qf.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qf.pojo.DtsAccountTrace;
import com.qf.service.DtsAccountTraceService;
import com.qf.util.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

@CrossOrigin("*")
@RestController
@RequestMapping("/admin/brokerage")
public class AdminBrokerageController {

    @Autowired
    DtsAccountTraceService accountTraceService;

    @RequestMapping("/list")
    public Object list(
            @RequestParam(name = "page",required = false,defaultValue = "1") Integer page,
            @RequestParam(name = "limit",required = false,defaultValue = "20") Integer limit,
            String username,
            String mobile,
            ArrayList<String> statusArray ,
            @RequestParam(name = "sort",required = false,defaultValue = "add_time") String sort,
            @RequestParam(name = "order",required = false,defaultValue = "desc") String order){


    IPage<DtsAccountTrace> iPage = accountTraceService.findPage(page,limit,username,mobile,statusArray,sort,order);

    Map<String,Object> data = new HashMap<>();
        data.put("total",iPage.getTotal());
        data.put("items",iPage.getRecords());

        return ResponseUtil.ok(data);

}

}
